import { shareAppMessageSet } from "../../../utils/config";
import { dataCollection } from "../../../utils/dataCollection";

let app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    logo: "",
    schoolName: "",
    detail:
      "耕耘驾驶培训已经有30年的历史。在深圳学车的10名学员中，有3位毕业于深港，被誉为驾培界的劳斯莱斯。我们秉承智能教学、轻松学车、高效服务的理念，持续创新数字化驾校服务。",
    content: "",
    themeCode: "",
    qualificationImage: <{ pic: string; picUrl: string; tag: string }[]>[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    const drivingSchool = wx.getStorageSync("currentDrivingSchool");
    console.log("drivingSchool", drivingSchool);
    this.setData({
      logo: drivingSchool.logo,
      schoolName: drivingSchool.fullName,
      // detail:'',
      content: "",
      qualificationImage: drivingSchool.qualificationPic,
      themeCode: wx.getStorageSync("themeCode"),
    });
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
    return { ...shareAppMessageSet() };
  },
  onHide() {
    dataCollection.setPageMapData("leave");
  },
  onUnload() {
    dataCollection.setPageMapData("leave");
  },
  onShow() {
    dataCollection.setPageMapData("enter", "资质认证");
  },
  onPreviewImage(res: any) {
    console.log(res.currentTarget.dataset.index);
    const urls: string[] = [];
    this.data.qualificationImage.forEach((item: any) => {
      urls.push(item.picUrl);
    });
    wx.previewImage({
      urls,
      showmenu: true,
      current: this.data.qualificationImage[res.currentTarget.dataset.index]
        .picUrl,
      fail: (e) => {
        console.log(e);
      },
    });
  },
});
